import { Component, OnInit } from '@angular/core';
// 服务
import {StorageService} from '../../services/storage.service'
// 指定组件的选择器 模板 以及样式
@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.less']
})
// 业务逻辑
export class SearchComponent implements OnInit {
  keyWord:string = ""
  selectList:any[]=[]
  datas:string[] = ['这是一种寂寞的天', '下着有些伤心的雨', '后面有点忘词了', '你知道吗']
  constructor(public storage: StorageService) {
    console.log(this.storage.get())
    this.keyWord= this.storage.name
   }
  ngOnInit(): void {
    console.log("初始化");
  }
  toSearch(){
    if (this.selectList.indexOf(this.keyWord)== -1) {
      this.selectList.push(this.keyWord)
      this.keyWord = ''
    }else {
      this.keyWord = ''
    }
  }
  toDel(keys){
    console.log(111);
    this.selectList.splice(keys,1)
  }
}
